package org.bbelovic.devel.futureexample;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

import org.bbelovic.devel.algorithms.recursive.Fibonacci;
import org.bbelovic.devel.algorithms.recursive.RecursiveAlgorithm;

public class FutureExample {

	public static void main(String[] args) {
		RecursiveAlgorithm<Long, Long> fibonacci = new Fibonacci(48);
		FutureTask<FutureExampleResult<Long>> ft = new FutureTask<>(new FutureExampleService<Long, Long>(fibonacci));
		ExecutorService executor = Executors.newFixedThreadPool(10);
		System.out.println("Starting future task");
		executor.execute(ft);
		System.out.println("Starting client no. 1");
		executor.submit(new FutureExampleClient<FutureExampleResult<Long>>(ft));
		System.out.println("Starting client no. 2");
		executor.submit(new FutureExampleClient<FutureExampleResult<Long>>(ft));


	}
}
